let namess = localStorage.getItem('已登录')
if(namess){
let spanB = document.createElement('span')
spanB.className = 'layui-badge'
spanB.style.position = "absolute"
spanB.style.right = '0'
spanB.style.top = '10px'
spanB.style.cursor = 'default'
spanB.style.padding = "0 3px !important"
let dataL = localStorage.getItem('cart')
let num = 0

if (dataL) {
    dataL = JSON.parse(dataL)
    dataL.forEach((v,i)=>{
        num+=v.num
    
    })
}
spanB.innerHTML = num
if(spanB.innerHTML==0){
    spanB.style.opacity=0
}else{
    spanB.style.opacity=1
}
document.querySelector('#menu-container').appendChild(spanB)
spanB.onclick = function () {
    window.location.href = 'http://127.0.0.1:5500/xiaomiyoupin/cart.html'

}
}